import UIKit

public class CustomViewRegistry {
    // MARK: - Types
    public typealias ViewBuilder = (_ attributes: [String: String], _ content: String) -> UIView?
    
    // MARK: - Properties
    public static let shared = CustomViewRegistry()
    private var viewBuilders: [String: [String: ViewBuilder]] = [:]
    
    private init() {}
    
    // MARK: - Registration
    public func register(
        tag: String,
        className: String,
        builder: @escaping ViewBuilder
    ) {
        if viewBuilders[tag] == nil {
            viewBuilders[tag] = [:]
        }
        viewBuilders[tag]?[className] = builder
    }
    
    // MARK: - View Creation
    public func createView(
        forTag tag: String,
        className: String?,
        attributes: [String: String],
        content: String
    ) -> UIView? {
        guard let className = className else { return nil }
        return viewBuilders[tag]?[className]?(attributes, content)
    }
} 